package com.harassment.interception.ui.fragments.listManagement;

import android.app.Activity;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AppCompatActivity;

import com.harassment.interception.R;
import com.harassment.interception.ui.fragments.interceptRecord.phoneFragment.PhoneFragment;
import com.harassment.interception.ui.fragments.interceptRecord.smsFragment.SmsFragment;
import com.harassment.interception.ui.fragments.listManagement.blackListFragment.BlackListFragment;
import com.harassment.interception.ui.fragments.listManagement.whiteListFragment.WhiteListFragment;

import java.util.ArrayList;
import java.util.List;

public class LMViewPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> mFragments;
    private List<CharSequence> mTagNames;
    private BlackListFragment mBlackListFragment;
    private WhiteListFragment mWhiteListFragment;

    public LMViewPagerAdapter(@NonNull Activity activity) {
        super(((AppCompatActivity) activity).getSupportFragmentManager());
        mFragments = new ArrayList<>();
        mBlackListFragment = new BlackListFragment();
        mWhiteListFragment = new WhiteListFragment();
        mFragments.add(mBlackListFragment);
        mFragments.add(mWhiteListFragment);

        mTagNames = new ArrayList<>();
        Resources resources = activity.getResources();
        mTagNames.add(resources.getString(R.string.black_list));
        mTagNames.add(resources.getString(R.string.white_list));
    }

    @Override
    public Fragment getItem(int position) {
        return (mFragments == null) ? null : mFragments.get(position);
    }

    @Override
    public int getCount() {
        return (mFragments == null) ? 0 : mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return (mTagNames == null) ? null : mTagNames.get(position);
    }

    public List<Fragment> getFragments() {
        return mFragments;
    }

    public void setFragments(List<Fragment> fragments) {
        mFragments = fragments;
    }

    public List<CharSequence> getTagNames() {
        return mTagNames;
    }

    public void setTagNames(List<CharSequence> tagNames) {
        mTagNames = tagNames;
    }

    public BlackListFragment getBlackListFragment() {
        return mBlackListFragment;
    }

    public void setBlackListFragment(BlackListFragment blackListFragment) {
        mBlackListFragment = blackListFragment;
    }

    public WhiteListFragment getWhiteListFragment() {
        return mWhiteListFragment;
    }

    public void setWhiteListFragment(WhiteListFragment whiteListFragment) {
        mWhiteListFragment = whiteListFragment;
    }
}
